<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    html,body {
      width: 100%;
      height: 100%;
    }
    * {
      margin: 0;
      padding: 0;
    }
    .container {
      width: 100%;
      height: 100%;
      background: url(./bg.png) no-repeat;
      background-size: cover;
    }
    .box {
      width: 1920px;
      height: 1080px;
      background: red;
      transform-origin: left top;
      position: fixed;
      left: 50%;
      top: 50%;
    }
    .top {
      width: 100px;
      height: 100px;
      background: hotpink;
      margin-left: 50px;
    }
    .bottom {
      width: 100px;
      height: 100px;
      background: skyblue;
      margin-left: 50px;
      margin-top: 100px;
    }
  </style>
</head>
<body>
  <!-- 
    优点: 不用自己计算宽高
    缺点: 左右会有留白
    基点调整到屏幕的正中间,随设备放大虽小
    而不是box的中间
    缩放基点调整到盒子box左上角
    把Box放在设备中间
   -->
  <div class="container">
    <div class="box">
      <div class="top">你好你啊啊十九大蛇口街道</div>
      <div class="bottom">阿书记漏打卡了阿水来到了 啊</div>
    </div>
  </div>
  <script>
    // 控制放大和缩小
    let box = document.querySelector('.box')
    box.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
    // 计算缩放比例
    function getScale (w=1920,h=1080) {
      // 设备视口/原型稿
      const ww = window.innerWidth / w
      const wh = window.innerHeight / h
      return ww<wh?ww:wh

      /*
        谁缩放比例小用谁 保证能全部显示
        ww<wh: 
      */

    }
    window.onresize = () => {
      box.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
    }
  </script>
</body>
</html>